// const HOST = "http://192.168.3.138:8000/";
const HOST = "https://www.csdashi.cn/";

export const URL = {
  reg:"personal/register/",   //注册
  vccode:"personal/getVerificationCode/",   //获取验证码
  login:"personal/goLogin/",    //登录（密码登录）
  vccodeLogin:"personal/noteLogin/",    //验证码登录
  findPwd:"personal/findPassword/",    //忘记密码
  userInfo: "personal/getPersonalData/",    //获取用户信息 
  editPersonalData: "personal/editPersonalData/",   //编辑个人资料
  logistics: "carservice/logistics/",   //大师物流 
  saveEditHeadImg: "personal/saveEditHeadImg/",    //保存用户头像
  feedBack: "personal/feedBack/",    //意见反馈
  saveFeedBackImg: "personal/saveFeedBackImg/",    //上传反馈图片
  createClaimOrder: "apiservice/createClaimOrder/",    //创建订单
  deleteShopCar: "apiservice/deleteShopCar/",
  getAboutUs: "personal/getAboutUs/",   //关于我们  
  userExtra: "personal/user-extra/",    //车商认证
  carRental:"carservice/car-rental/",    //创建车位出租  
  rent:"carservice/create-demand-rental/",   //创建车位求租
  rentList: "carservice/get-rental-list/",  //获取出租列表
  Magdebrug:"carservice/get-demandrent-list/",   //获取求租列表
  show4SReports: "personal/show4SReports/",   //获取车险报告
  rentDetail: "carservice/get-detail-rental/",  //获取出租详情
  MagdebrugDetail:"carservice/get-detail-demand/",   //求租
  getMotorcycleType: "apiservice/getMotorcycleType/",    //VIN码查车型
  getVinGetVehicleModel: "apiservice/vinGetVehicleModel/",    //查询车型
  wxpayverify: "wxpayverify/payOrder/",    //统一下单支付接口
  balancePay: "wxpayverify/balancePay/",    //余额支付
  masterMionPay: "wxpayverify/masterMionPay/",    //大师币支付
  myClaimList: "personal/myClaimList/",     //我的车险列表
  getConstruction: "apiservice/getConstruction/",    //车辆结构查
  getParts: "apiservice/getParts/",   //获取车辆结构对应配件
  getRelatedParts:"apiservice/getRelatedParts/",    //获取相关配件
  getPartsPrice: "apiservice/getPartsPrice/",   //获取配件价格
  OESearch: "apiservice/oeGetPartsPrice/",     //OE号精确查询
  getOrderNum: "apiservice/getOrderNum/",   //获取用户报价清单数量
  getSupportCity:"apiservice/getSupportCity/",    //获取违规查询省份
  addshoping: "apiservice/addshoping/",   //添加购物车
  createOrder: "apiservice/createOrder/",   //提交清单获取准确报价
  partsList: "apiservice/partsList/",   //购物车配件列表
  orderList: "apiservice/orderList/",   //我的订单列表
  getWz: "apiservice/getWz/",    //违规查询
  parseDrivingLicense:"apiservice/parseDrivingLicense/",
  createRecruitment: "carservice/createRecruitment/",   //发布职业
  myRecruitmentList: "carservice/myRecruitmentList/",   //获取我的招聘列表
  getCompanyInfo: "carservice/getCompanyInfo/",    //获取公司信息
  myCompany: "carservice/myCompany/",   //编辑我的公司
  getRecruitmentInfo: "carservice/getRecruitmentInfo/",   //获取指定招聘详情
  updateStatus: "carservice/updateStatus/",   //上下线
  judgeEditInfo: "carservice/judgeEditInfo/",   //判断是否属于自己的信息
  shareRecruitment: "carservice/shareRecruitment/",   //垂直招聘分享
  support:"carservice/support/",    //点赞
  getCity: "carservice/getCity/",   //获取城市
  bindBankInfo: "personal/bindBankInfo/",     //绑定银行卡信息
  manageBankCard: "personal/manageBankCard/",   //管理银行卡
  setDefaultBankCord: "personal/setDefaultBankCord/",   //设置默认银行卡
  deleteBankCard: "personal/deleteBankCard/",   //删除银行卡
  myMessage: "personal/myMessage/",    //我的消息
  delMymessage: "personal/delMymessage/",   //清空消息
  balanceUseRecorde: "personal/balanceUseRecorde/",    //余额使用记录
  myAccountInfo: "personal/myAccountInfo/",   //我的账户信息
  withdrawDeposit: "personal/withdrawDeposit/",   //提现
  getWithdrawInfo: "personal/getWithdrawInfo/",   //获取提现信息
  myMasterCoin: "personal/myMasterCoin/",   //我的大师币
  cashCoupon: "personal/cashCoupon/",    //现金券
  getAllCity: "apiservice/getAllCity/",   //获取车辆估价城市
  getUsedCarPrice: "apiservice/getUsedCarPrice/",   //估价
  getCarBrandList: "apiservice/getCarBrandList/",   //获取车辆品牌
  getCarSeriesList: "apiservice/getCarSeriesList/",   //获取车系
  getCarModelList: "apiservice/getCarModelList/",   
  getBrand:"carservice/getBrand/",    
  getseries: "carservice/getseries/",
  getgenre: "carservice/getgenre/",
  getListSet: "carservice/getListSet/",   //根据注册日期获取车龄、服务期限、服务范围
  getRange: "carservice/getRange/",   //根据注册日期获取车龄、服务期限、服务范围
  getprice: "carservice/getprice/",   //获取g该车指导价
  getResult: "carservice/getResult/",   //根据车辆指导价、车龄、赔偿限额、服务期限、服务范围
  warranty: "carservice/warranty/",
  maintenReports: "personal/maintenReports/",
  showMaitenReport: "personal/showMaitenReport/",
  createMainOrder: "apiservice/createMainOrder/",
  editInfo: "carservice/editInfo/",   //编辑垂直招聘信息
  getProtocol: "personal/getProtocol/",
  verifyUser: "personal/verifyUser/",
  getMyRentalList: "carservice/getMyRentalList/",   //获取我的租赁列表
  deleteRental: "carservice/deleteRental/",   //删除指定出租信息
  putaway: "carservice/putaway/",   //车位租赁上架或下架
  saveEditInfo: "carservice/saveEditInfo/",
  editRentalImg: "carservice/editRentalImg/",
  getMyDemandRentList: "carservice/getMyDemandRentList/",
  delDemandRental: "carservice/delDemandRental/",
  putAwayDemand: "carservice/putAwayDemand/",
  saveDemandInfo: "carservice/saveDemandInfo/",
  getCart: "apiservice/getShopNum/",
  filterVehicleList: "apiservice/filterVehicleList/",
  verifyPhone:"personal/verifyPhone/",
  advanceOrder: "apiservice/advanceOrder/",    //预订单详情页
  oeIdGetPartsPicture: "apiservice/oeIdGetPartsPicture/",
  advanceClaimOrder: "apiservice/advanceClaimOrder/",
  shareRentImage: "carservice/shareRentImage/",   //租赁分享图
  shareRecruitImage: "carservice/shareRecruitImage/",   //招聘分享图
  redMessage: "personal/readMessage/",
  
};

export const imgUrl = "https://www.csdashi.cn/static/"

export const POST = (url,params,fun,fail)=> {
 wx.getNetworkType({
   complete: function (resNetwork) {
     if (resNetwork.networkType == "none"){
       wx.showToast({
         title: "好像没网了 ~",
         icon: "none",
         duration: 1500
       });
       wx.onNetworkStatusChange(function(res){
         if(res.networkType != "none"){
           POST(url, params, fun);
         }
       });
     }else{
       wx.request({
         url: HOST + url,
         data: params,
         method: "POST",
         dataType: "json",
         header: { "content-type": "application/x-www-form-urlencoded" },
         success(res) {
           if (res.data.status == "success") {
             return typeof fun === "function" && fun(true, res);
           } else {
             return typeof fun === "function" && fun(false, res);
           }
         },
         fail() {
           if (fail && typeof fail === "function"){
             fail();
            }
           wx.showToast({
             title: "服务好像出了点问题 ~",
             icon: "none",
             mask: true,
             duration: 1500
           });
         }
       }); 
     }
   },  
 })
  
}


export const GET = (url,params,fun) => {
  
  wx.getNetworkType({
    complete: function (resNetwork) {
      if (resNetwork.networkType == "none") {
        wx.showToast({
          title: "好像没网了 ~",
          icon: "none",
          duration: 1500
        });
        wx.onNetworkStatusChange(function (res) {
          if (res.networkType != "none") {
            POST(url, params, fun);
          }
        });
      } else {
        wx.request({
          url: HOST + url,
          data: params,
          method: "GET",
          dataType: "json",
          header: { "content-type": "application/x-www-form-urlencoded" },
          success(res) {
            if (res.data.status == "success") {
              return typeof fun === "function" && fun(true, res);
            } else {
              return typeof fun === "function" && fun(false, res);
            }
          },
          fail() {
            wx.showToast({
              title: "服务好像出了点问题 ~",
              icon: "none",
              mask: true,
              duration: 1500
            });
          }
        });
      }
    },
  })
}